package com.elmo.movies;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
	private Context mContext;

    public ImageAdapter(Context c) {
        mContext = c;
    }

    public int getCount() {
        return mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(150, 150));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(4, 4, 4, 4);
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(mThumbIds[position]);
        return imageView;
    }

    // references to our images
    private Integer[] mThumbIds = {
            R.drawable.emoticon_01,  R.drawable.emoticon_02,
            R.drawable.emoticon_03,  R.drawable.emoticon_04,
            R.drawable.emoticon_05,  R.drawable.emoticon_06,
            R.drawable.emoticon_07,  R.drawable.emoticon_08,
            R.drawable.emoticon_09,  R.drawable.emoticon_10,
            R.drawable.emoticon_11,  R.drawable.emoticon_12,
            R.drawable.emoticon_13,  R.drawable.emoticon_14,
    };
}


